const express = require('express');
const app = express();
app.get('/', (request, response) => {
    response.send('Hello, this is a data server');
});
app.post('/server', (request, response) => {
    //设置响应头 设置允许跨域
    response.setHeader('Access-Control-Allow-Origin', '*');
    response.send('HELLO Android POST');
});
app.all('/json-server', (request, response) => {
    //设置响应头 设置允许跨域
    response.setHeader('Access-Control-Allow-Origin', '*');
    //响应头
    response.setHeader('Access-Control-Allow-Headers', '*');
    //响应一个数据
    const data = {
        name: 'hello'
    };
    //对对象字符串进行转换
    let str = JSON.stringify(data);
    //设置响应体
    response.send(str);
});
app.listen(9000, () => {
    console.log("服务端已经启动，8000端口正在监听....");
});